package org.black.phoneUtility.sms.reply.app.fragment;

import org.black.phoneUtility.R;

import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.DialogFragment;
import android.content.DialogInterface;
import android.os.Bundle;

public class SmsReplyReplyTimesModeDialogFragment extends DialogFragment implements
		DialogInterface.OnClickListener {
	public static final String TAG = SmsReplyReplyTimesModeDialogFragment.class
			.getName();

	public interface SmsReplyTimesModeDialogFragmentListener {
		public void onSmsReplyTimesModeDialogFragmentAlwaysClick();

		public void onSmsReplyTimesModeDialogFragmentLimitedTimesClick();
	}

	private SmsReplyTimesModeDialogFragmentListener smsReplyTimesModeDialogFragmentListener;

	@Override
	public void onAttach(Activity activity) {
		super.onAttach(activity);
		try {
			smsReplyTimesModeDialogFragmentListener = (SmsReplyTimesModeDialogFragmentListener) activity;
		} catch (ClassCastException e) {
			throw new ClassCastException(activity.toString()
					+ " must implement SmsReplyTimesModeDialogFragmentListener");
		}
	}

	@Override
	public Dialog onCreateDialog(Bundle savedInstanceState) {
		super.onCreateDialog(savedInstanceState);
		return new AlertDialog.Builder(getActivity())
				.setTitle(R.string.sms_reply_add_edit_reply_times_title)
				.setItems(R.array.sms_reply_add_edit_reply_times_array, this)
				.create();

	}

	@Override
	public void onClick(DialogInterface dialog, int which) {
		switch (which) {
		case 0:
			this.smsReplyTimesModeDialogFragmentListener
					.onSmsReplyTimesModeDialogFragmentAlwaysClick();
			break;
		case 1:
			this.smsReplyTimesModeDialogFragmentListener
					.onSmsReplyTimesModeDialogFragmentLimitedTimesClick();
			break;
		default:
			break;
		}

	}

}
